﻿using System;
using System.Transactions;
using Xtensive.Storage;

namespace Sherwood.Content.DO
{
    public class DataSession : IDataSession, IDisposable
    {
        private readonly SessionProvider _sessionProvider;

        public DataSession(SessionProvider sessionProvider)
        {
            _sessionProvider = sessionProvider;
            Session = Session.Open(_sessionProvider.Domain);
        }

        public Session Session { get; private set; }

        public IDataSessionScope CreateScope(IsolationLevel isolationLevel)
        {
            return new SessionScope(Session, isolationLevel);
        }

        public void Dispose()
        {
            Session.Dispose();
        }
    }
}